import { IRouterConfig, lazy } from 'ice';
import SecurityLayout from '@/Layouts/SecurityLayout';
import BaseLayout from '@/Layouts/BaseLayout';

const Login = lazy(() => import('@/pages/Login'));
const Register = lazy(() => import('@/pages/Register'));
const ForgetPwd = lazy(() => import('@/pages/ForgetPwd'));
const NotFound = lazy(() => import('@/pages/404'));
const Home = lazy(() => import('@/pages/Home'));
const ProjectManageAll = lazy(() => import('@/pages/ProjectManageAll'));
const ProjectManageMy = lazy(() => import('@/pages/ProjectManageMy'));
const ProjectManageAdd = lazy(() => import('@/pages/ProjectManageAdd'));

const routerConfig: IRouterConfig[] = [
  {
    exact: true,
    path: '/login',
    component: Login,
    pageConfig: {
      title: '登录'
    }
  },
  {
    exact: true,
    path: '/register',
    component: Register,
    pageConfig: {
      title: '注册'
    }
  },
  {
    exact: true,
    path: '/forgetpwd',
    component: ForgetPwd,
    pageConfig: {
      title: '忘记密码'
    }
  },
  {
    exact: true,
    path: '/404',
    component: NotFound,
    pageConfig: {
      title: '未找到'
    }
  },
  {
    exact: false,
    path: '/',
    component: SecurityLayout,
    children: [
      {
        exact: false,
        path: '/',
        component: BaseLayout,
        children: [
          {
            exact: true,
            path: '/',
            component: Home,
            pageConfig: {
              title: '主页'
            }
          },
          {
            exact: true,
            path: '/project/all',
            component: ProjectManageAll,
            pageConfig: {
              title: '所有项目'
            }
          },
          {
            exact: true,
            path: '/project/my',
            component: ProjectManageMy,
            pageConfig: {
              title: '我的项目'
            }
          },
          {
            exact: true,
            path: '/project/add',
            component: ProjectManageAdd,
            pageConfig: {
              title: '创建项目'
            }
          },
          {
            exact: false,
            path: '/*',
            component: NotFound,
            pageConfig: {
              title: '未找到'
            }
          },
        ],
      },
    ],
  },
];

export default routerConfig;
